import java.awt.Color;

import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTextPane;

/**
 * Title:  Configure.java
 * Description:  Provide the function of changing the text's color
 * Copyright:    Copyright (c) 2010
 * @author WANG Jiechao
 * @version 1.0
 */

public class Configure {
	JMenu configureMenu;
	JMenuItem colorItem;
	
	public Configure(){
		configureMenu = new JMenu("Configure");
		colorItem = new JMenuItem("Color");
		configureMenu.add(colorItem);		
	}
	
	public JMenu getConfigureMenu(){
		return configureMenu;
	}
	
	public JMenuItem getColorItem(){
		return colorItem;
	}
	
	public void changeColor(JFrame localGroup,JTextPane text){
		Object[] options = {"Yes, use the default one",
        "No, i wanna change"};
		int n = JOptionPane.showOptionDialog(localGroup,
				"It is recommended that you use the default black color",
				"Font Color",
				JOptionPane.YES_NO_OPTION,
				JOptionPane.QUESTION_MESSAGE,
				null,     //don't use a custom Icon
				options,  //the titles of buttons
				options[0]); //default button title


        if (n==JOptionPane.NO_OPTION) {
            Color color=JColorChooser.showDialog(localGroup,"Font Color",text.getForeground());
            if(color!=null)
            	text.setForeground(color);        
        }
        else 
        	text.setForeground(Color.BLACK);
	}

}
